<?php
// 后台网址配置文件模块
class ConfigAction extends CommonAction {

	function __construct(){
		parent::__construct();
		$this->root_dir = dirname(dirname(dirname(dirname(__FILE__)))).'/';//存放xml文件
		$this->root_dir_file = $this->root_dir.'siteconfig.inc.php';
	}

	public function _before_index(){
		$siteconfig = require $this->root_dir_file;//前端配置文件
		$this->assign('siteconfig', $siteconfig);
	}

	public function update(){
		$str = "<?php \n";
		$str .= "if (!defined('THINK_PATH')) exit();\n";
		$str .= "return array(\n";
		foreach($_POST as $key=>$val){
			$str .="'$key'=>'$val',\n";
		}
		$str .=");\n";
		$str .="?>";

		$rs = file_put_contents($this->root_dir_file, $str);
		$this->success('更新成功');
	}

}
?>